package modelgraph;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EcoreUtil;

public class ModelGraph
{
	private List<ModelGraphNode> nodes = new ArrayList<ModelGraphNode>();
	private List<ModelGraphEdge> edges = new ArrayList<ModelGraphEdge>();
	
	public void addNode(ModelGraphNode node)
	{
		nodes.add(node);
	}
	
	public List<ModelGraphNode> getNodes()
	{
		return nodes;
	}
	
	public void addEdge(ModelGraphEdge edge)
	{
		edges.add(edge);
	}
	
	public List<ModelGraphEdge> getEdges()
	{
		return edges;
	}
	
	public boolean containsElement(EObject ele)
	{
		for (ModelGraphNode node : nodes)
		{
			if (node.getObj().equals(ele))
				return true;
		}
		return false;
	}
	
	public boolean containsElement(String id)
	{
		for (ModelGraphNode node : nodes)
		{
			if ((node.getObj().eResource().getURIFragment(node.getObj())).equals(id))
				return true;
		}
		return false;
	}
	
	public ModelGraphNode getNodeByID(String id)
	{
		for (ModelGraphNode node : nodes)
		{
			if ((node.getObj().eResource().getURIFragment(node.getObj())).equals(id))
				return node;
		}
		return null;
	}
}
